package com.hong.spring.transaction.dao;

import com.hong.spring.transaction.entity.UserRole;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @Auther: csh
 * @Date: 2020/8/4 18:32
 * @Description:
 */
@Repository
public class UserRoleDao {
    private static Logger log = LogManager.getLogger(UserRoleDao.class);

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public int save(UserRole user){
        String sql = "Insert into user_role(user_id,role_id)values(?,?);";
        int save = jdbcTemplate.update(sql,user.getUserId(),user.getRoleId());
        log.info("保存结果{}",save>0?"成功":"失败");
        return save;
    }

}
